<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%><%@ page import="java.util.Set"
%><%@ page import="java.util.Iterator"
%><%@ page import="com.util.StringUtil"
%><%@ page import="com.kt.bit.bidw.common.authority.SessionInfo"
%><%@ page import="com.kt.bit.bidw.common.authority.SessionInfoSupport"
%><%@ page import="com.kt.bit.bidw.common.util.CustomProperties"
%><%
	String contextPath =	request.getContextPath();
	contextPath = 			(contextPath.endsWith("/") ? contextPath.substring(0, contextPath.length() - 1) : contextPath);

	/*
	 * 세션에서 사용자정보 조회 후 javascript 문자열로 변환
	 */
	SessionInfo info =		SessionInfoSupport.getSessionAttribute(request.getSession());
	StringBuffer usrBuf =	new StringBuffer();
	
	if (info != null) {
		/* 사용자정보가 웹소스에 노출될 경우 보안측면에서 문제가 될 소지가 있으므로 처리하지 않도록 변경
		usrBuf.append("userid:\"").append(info.getUserId()).append("\",")
			.append("userMail:\"").append(info.getUserMail()).append("\",")
			.append("userPhoneNo:\"").append(info.getUserPhoneNo()).append("\",")
			.append("mstrUserId:\"").append(info.getMstrUserId()).append("\",")
			.append("mstrAuthMode:\"").append(Integer.toString(info.getMstrAuthMode())).append("\",")
			.append("userName:\"").append(info.getUserName()).append("\",")
			.append("userOrgCd:\"").append(info.getUserOrgCd()).append("\",")
			.append("userOrgName:\"").append(info.getUserOrgName()).append("\",")
			.append("aMode:\"").append(Integer.toString(info.getAMode())).append("\",")
			.append("isAgent:\"").append(info.isAgent() ? "y" : "n").append("\",")
			.append("isRegUser:\"").append(info.isRegUser() ? "y" : "n").append("\",")
			.append("isMstrUser:\"").append(info.isMstrUser() ? "y" : "n").append("\"");

		if (info.getRoleGroupName() != null) {
			usrBuf.append(",roleGroupName:[");
			for (int i = 0; i < info.getRoleGroupName().length; i++) {
				usrBuf.append(i == 0 ? "" : ",").append("\"").append(info.getRoleGroupName()[i]).append("\"");
			}
			usrBuf.append("]");
		}
		if (info.getUserGroupName() != null) {
			usrBuf.append(",userGroupName:[");
			for (int i = 0; i < info.getUserGroupName().length; i++) {
				usrBuf.append(i == 0 ? "" : ",").append("\"").append(info.getUserGroupName()[i]).append("\"");
			}
			usrBuf.append("]");
		}
		*/
	}

	Set<String> set =		(Set<String>)request.getAttribute("authority");
	StringBuffer autBuf =	new StringBuffer();
	if (set != null) {
		Iterator<String> iterator =	set.iterator();
		while (iterator.hasNext()) {
			if (!"".equals(autBuf.toString())) {
				autBuf.append(",");
			}
			autBuf.append("\"").append(iterator.next()).append("\"");
		}
	}
	
	String programID =		(String)request.getAttribute("programID");
	String helpUrl =		(String)request.getAttribute("helpUrl");
	String menuId =	StringUtil.nullToString(request.getParameter("_menuId"),"-");
	
	CustomProperties prop = CustomProperties.getInstance();
	String websquareUrl =	prop.getProperty("websquare.url");
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:ev='http://www.w3.org/2001/xml-events' xmlns:w2='http://www.inswave.com/websquare' xmlns:xf='http://www.w3.org/2002/xforms'>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
		<title>BIT BI/DW PORTAL</title>
		<script type="text/javascript" src="javascript.wq?q=/bootloader"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/app/common/messages.js.stream"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/_custom/javascript/common/common.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/_custom/javascript/common/WSHelper.js"></script>
        <script	type="text/javascript" src="${pageContext.request.contextPath}/_custom/javascript/jquery-1.6.4.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/_custom/javascript/common/validator.js"></script>
		<script type="text/javascript">
			/*
			 * 사용자세션정보, 화면권한, 기타 전역변수 설정.
			 */
			var _contextRoot =	"<%= contextPath %>";
			var _servletRoot =	"<%= contextPath %>/app/";
			var _userInfo =		{<%= usrBuf.toString() %>};
			var _authority =	[<%= autBuf.toString() %>];
			var _programID =	"<%= programID %>";
			var _helpUrl =		"<%= helpUrl %>";
			var _WSHOME = 		"${pageContext.request.contextPath}<%=websquareUrl%>?w2xPath=";
			var _programTitle = "";
			var _menuId = "";
			<% if(!menuId.equalsIgnoreCase("") && !menuId.equalsIgnoreCase("-")){ %>
			_programTitle = parent.getTitle("<%= menuId %>");
			_menuId = "<%= menuId %>";
			<% } %>
			
			function _hasAuthority(job) {
				for (var i = 0; i < _authority.length; i++) {
					if (_authority[i] == job) {
						return true;
					}
				}	
				return false;
			}
			
			function isReadable() 			{ return _hasAuthority("R"); }
			function isInsertable() 		{ return _hasAuthority("I"); }
			function isDeletable() 			{ return _hasAuthority("D"); }
			function isUpdatable() 			{ return _hasAuthority("U"); }
			function isAdminReadable() 		{ return _hasAuthority("AR"); }
			function isAdminInsertable()	{ return _hasAuthority("AI"); }
			function isAdminDeletable() 	{ return _hasAuthority("AD"); }
			function isAdminUpdatable() 	{ return _hasAuthority("AU"); }
				
			window.onload = init;

			function init() {
				try{
					WebSquare.startApplication();
				} catch(e) {
					alert(e.message);
				}
			}
			
 			function resizeLayout(){
				parent.resize_frame(document.getElementById("warp").scrollHeight);
			}
			
		</script>
	</head>
<body></body>
</html>